import { IStrategyOptions, IStrategyOptionsWithRequest, Strategy } from 'passport-local';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import express from 'express';

@Injectable()
export class ReqKeyAndSecretStrategy extends PassportStrategy(Strategy, 'req-key-secret') {
    constructor() {
        super({
            passReqToCallback: true
        } as IStrategyOptionsWithRequest);
    }

    // async validate(req: express.Request,
    //     username: string,
    //     password: string,
    //     done: Function): Promise<any> {
    //     console.log(req)
    //     // 相关校验
    //     return {
    //         username: "username",
    //         id: "id"
    //     }
    // }validate

    validate(username: string, password: string): any {
        console.log(username)
        return {
            username: "username",
            id: "id"
        }
    }
}
